package br.com.rapidrest.demo.web.engine.phonebook;

import java.io.Serializable;

import javax.ejb.EJB;

import br.com.rapidrest.annotation.Inject;
import br.com.rapidrest.demo.domain.PhoneBook;
import br.com.rapidrest.demo.service.PhoneBookService;
import br.com.rapidrest.demo.web.engine.Home;
import br.com.rapidrest.util.MessagesBundle;

public class NewPhoneBook implements Serializable {

	private static final long serialVersionUID = 3897008439565714080L;

	@Inject
	private MessagesBundle messages;

	@EJB
	private PhoneBookService phoneBookService;

	private String name;

	public Object save() {
		PhoneBook phoneBook = new PhoneBook(name);
		phoneBookService.savePhoneBook(phoneBook);
		return Home.class;
	}

	public MessagesBundle getMessages() {
		return messages;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
